using Imaginarium.stats;
using Imaginarium.effect;
using System.Xml;
using Imaginarium.XML;
using System.Collections.Generic;
namespace Imaginarium.jobs.skills
{
    public class Skill
    {

        public int idSkill { get; set; }
        public int maxLevel { get; set; }
        public int mpConsume { get; set; }
        public string name { get; set; }
        public string description{ get; set; }
        public Effect effect { get; set; }
        public List<SkillRequirement> requirements { get; set; }
        public BaseDamage baseDamage { get; set; }

        //TODO Privatizar
        public BaseDamage incrementalDamage { set; get; }
        public Effect incrementalEffect { set; get; }
        public int incrementalMpConsume { set; get; }
        
        public Skill()
        {

        }
        public Skill(XmlElement element) {
            this.idSkill = XmlHelper.getIntByTagname(element, XmlParameters.SKILL_ID);
            this.maxLevel = XmlHelper.getIntByTagname(element, XmlParameters.SKILL_MAX_LEVEL);
            this.mpConsume = XmlHelper.getIntByTagname(element, XmlParameters.SKILL_MP_CONSUME);
            this.name = XmlHelper.getStringByTagname(element, XmlParameters.SKILL_NAME);
            this.description = XmlHelper.getStringByTagname(element, XmlParameters.SKILL_DESCRIPTION);
            this.effect = new Effect(XmlHelper.getXmlElementByTagname(element, XmlParameters.SKILL_EFFECT));
            this.incrementalDamage = new BaseDamage(XmlHelper.getXmlElementByTagname(element,XmlParameters.SKILL_INCREMENTAL_BASE_DAMAGE));
            this.incrementalEffect = new Effect(XmlHelper.getXmlElementByTagname(element,XmlParameters.SKILL_INCREMENTAL_EFFECT));
            this.incrementalMpConsume= XmlHelper.getIntByTagname(element,XmlParameters.SKILL_INCREMENTAL_MP_CONSUME);
            XmlNodeList nodeList = XmlHelper.getXmlNodeListByTagname(element,XmlParameters.SKILL_REQUIREMENT_LIST);
            if (nodeList.Count > 0)
            {
                requirements = new List<SkillRequirement>();
                foreach (XmlElement xe in nodeList)
                {
                    this.requirements.Add(new SkillRequirement(xe));
                }
            }
            this.baseDamage = new BaseDamage(XmlHelper.getXmlElementByTagname(element, XmlParameters.SKILL_BASE_DAMAGE));
        }
        public override string ToString()
        {
            string ans = "";
            ans += "idSkill: " + idSkill + "\n";
            ans += "maxLevel: " + maxLevel + "\n";
            ans += "mpConsume: " + mpConsume + "\n";
            ans += "name: " + name + "\n";
            ans += "description: " + description + "\n";
            ans += "effect: " + effect.ToString() + "\n";
            ans += "Requirements: " + "\n";
            int i = 0;
            foreach (SkillRequirement requirement in requirements) {
                ans += "Requirement["+ i +"]: "+ requirement.ToString() + "\n";    
            }
            ans += (i != 0) ? "End Requirements List \n" : "";
            ans += "BaseDamage: " + baseDamage.ToString() + "\n";
            return ans;
        }
    }
}